package com.controller;

import java.io.IOException;
import java.io.PrintWriter;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

//不要忘记写@WebServlet注释
@WebServlet("/Success")
public class SuccessServlet extends HttpServlet {

	//重写doGet方法
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		this.doPost(req, resp);
	}

	//重写doPost方法
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		//创建一个out输出流对象
		PrintWriter out = resp.getWriter();
		//打印成功登录的页面
 out.println("<html><head><title>登录成功的界面</title></head>");
 out.println("<body bgcolor='pink'>");
 out.println("<h1>用户"+req.getParameter("username")+"你好,欢迎您登录学生信息管理系统</h1><hr>");
 out.println("<table><tr><td>学生姓名</td><td>学生学号</td><td>学生宿舍号</td><td>学生手机号</td></tr>");
 out.println("<tr><td>小明</td><td>001</td><td>3-423</td><td>158898989</td></tr>");
 out.println("<tr><td>小强</td><td>002</td><td>3-424</td><td>158898444</td></tr>");
 out.println("<tr><td>小红</td><td>003</td><td>3-425</td><td>158898555</td></tr>");
 out.println("</table></body></html>");
    	//关闭输出流
 out.close();
	}	
}
